<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>

<head>

<title>CodeToHtml Sample</title>
<link rel="stylesheet" type="text/css" href="../../../docs/rotor.css">
</head>

<body>

<h1>CodeToHtml Sample</h1>
<h2>Sample Overview</h2>
<p>This sample program can be used to create an HTML file containing color-coded 
source code, in various languages including JScript and C#.</p>
<p>This sample was written in JScript.</p>
<p>Some features:</p>
<ul>
  <li>Support for coloring numbers and compiler directives.</li>
  <li>Fully extensible .ini and command-line driven architecture.</li>
  <li>Reads correct .ini file for JScript and C# depending on file extension.</li>
  <li>Dynamic replacement of strings in the output file.</li>
</ul>
<h3>Extensible Architecture</h3>
<p>Anything you add in the .ini file or on the command-line gets added to the 
global g_objOptions object, so you can use it in a dynamic 
replacement as specified in the file replace.ini. </p>
<p>The default behavior is that extensions .cs and .js are recognized and the 
correct .ini files loaded for that language. To support another language, copy 
the js_* files and rename them to &lt;lang_extention&gt;_*. Then modify the files to 
match the correct values for the new language.</p>
<ul>
  <li>&lt;lang&gt;_codetohtml.ini<ul>
    <li>Contains the name of the language, the other INI files, and the CSS file 
    to use.</li>
  </ul>
  </li>
  <li>&lt;lang&gt;_keywords.ini<ul>
    <li>Contains language keywords.</li>
  </ul>
  </li>
  <li>&lt;lang&gt;_userdefined.ini
  <ul>
    <li>Contains user-defined types to special case.</li>
  </ul>
  </li>
  <li>&lt;lang&gt;_futurereserved.ini
  <ul>
    <li>Contains future reserved words in the language.</li>
  </ul>
  </li>
</ul>
<p>Examine the default <code>js_replace.ini</code> and <code>header.txt</code> 
files to see the sorts of things that you can do to with the .ini files.</p>

<h2>Sample Source and Build Output Locations</h2>
<p>The sample source is found in sscli20\samples\utilities\codetohtml.</p>
<p>The source file is:</p>
<ul class="none">
  <li><a href="codetohtml.js">codetohtml.js</a></li>
</ul>
<p>The build output location is %_NTTREE%\samples\utilities\codetohtml.&nbsp; 
The output file is an executable assembly named codetohtml.exe.</p>
<h2>Building the Sample</h2>
<p>All samples are built from the buildall script.&nbsp; </p>
<p>You can also build all the samples by switching to the root of the sample 
directory, sscli20\samples, and typing <code>build -c</code>.</p>
<p>You can build this specific sample by switching to the sample directory and 
typing <code>build -c</code>.</p>
<h2>Running the Sample</h2>
<p>These steps require that the Shared Source CLI (SSCLI) be already built and 
functional.</p>
<p>This sample requires the files &lt;lang&gt;_codetohtml.ini, &lt;lang&gt;_keywords.ini, 
&lt;lang&gt;_userdefined.ini, and &lt;lang&gt;_futurereserved.ini to be present in the 
current directory where the application is launched.</p>
<ol>
  <li>Run  env.bat. </li>
  <li>Switch to the %_NTTREE%\samples\utilities\codetohtml directory.</li>
  <li>Type the following command:<blockquote>
    <p>clix codetohtml <i>sourcefilename</i></p>
  </blockquote>
  </li>
</ol>
<blockquote>
  <p>where <i>sourcefilename</i> is the full path to a C# or JScript source 
  file.&nbsp; The generated HTML file will be placed in the same directory as 
  the source file.</p>
</blockquote>
<hr>
<p><i>Copyright (c) 2006 Microsoft Corporation. All rights reserved.</i></p>

</body>

</html>